<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="author" content="lijinbo" />
    <title>6-03常用动画合集</title>
  </head>
  <style>
    body {
      overflow: hidden;
    }

    .content {
      width: 100%;
      height: 30px;
      margin: 20px 0;
      position: relative;
    }

    .content div {
      position: absolute;
      left: 0;
      top: 0;
    }

    .box {
      width: 80px;
      height: 30px;
      text-align: center;
      background-color: rgb(87, 192, 61);
      margin-bottom: 12px;
    }

    .box_lang {
      width: 150px;
    }

    .max1 {
      height: 230px;
    }

    #box5 {
      width: 300px;
      height: 200px;
      border-radius: 4px;
      top: -300px;
      left: 45%;
      transform: translateX(-50%);
    }
  </style>

  <body>
    <button onclick="reset()">重置</button>
    <button onclick="start()">开始</button>
    <div class="content">
      <div class="box box_lang" id="box5" onclick="closeDialog()">点击关闭弹窗</div>
    </div>
    <h2>基础使用</h2>
    <div class="max1">
      <div class="content">
        <div class="box" id="box1">单个属性</div>
      </div>
      <div class="box" id="box2">多个属性</div>
      <div class="box" id="box3">链式调用</div>
    </div>
    <h2>更多示例</h2>
    <p><button onclick="openDialog()">缓动弹窗</button></p>
    <div class="box box_lang" id="box4">开始/暂停</div>
    <script type="module">
      import { startAnimation } from '/utils/module/McAnimation.js'
      function start() {
        startAnimation(document.getElementById('box1'), { left: '800px' })
        startAnimation(document.getElementById('box2'), {
          width: '800px',
          height: '60px',
          opacity: 0.5
        })
        startAnimation(document.getElementById('box3'), { width: '500px' })
          .then((dom) => {
            return startAnimation(dom, { height: '100px' })
          })
          .then((dom) => {
            return startAnimation(dom, { opacity: 0.5 })
          })
          .then((dom) => {
            return startAnimation(dom, { opacity: 1 }, 500)
          })
          .then((dom) => {
            return startAnimation(dom, { height: '30px' }, 400)
          })
          .then((dom) => {
            return startAnimation(dom, { width: '80px' }, 300)
          })
      }
      function openDialog() {
        startAnimation(document.getElementById('box5'), { top: '500px' }, 1200, 'easeOutBack')
      }
      function closeDialog() {
        startAnimation(document.getElementById('box5'), { top: '-300px' }, 800, 'easeOutExpo')
      }
      var box4 = document.getElementById('box4')
      let box4Ani = new Ani(box4)
      box4.onmouseenter = function () {
        box4Ani.start({ width: '600px' })
      }
      box4.onmouseleave = function () {
        box4Ani.stop()
      }
      function reset() {
        location.reload()
      }
    </script>
  </body>
</html>
